package com.example.fresheveryday.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.fresheveryday.po.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.fresheveryday.po.Product;
import org.apache.ibatis.annotations.*;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ll
 * @since 2023-07-08
 */
@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
    @Select("select * from" + " comment ${ew.customSqlSegment} " )
    @Results({
            @Result(column = "user_id",property = "user",one = @One(select = "com.example.fresheveryday.mapper.UserMapper.selectById")),
            @Result(column = "product_id",property = "product",one = @One(select = "com.example.fresheveryday.mapper.ProductMapper.selectById"))
    })
    IPage<Comment> getCommentByConditions(IPage<Comment> page, @Param("ew") Wrapper wrapper);
    @Select("select count(comment_id) from comment ${ew.customSqlSegment}")
    int countByConditions(@Param("ew") Wrapper wrapper);
    @Select("select * from" + " comment  " )
    @Results({
            @Result(column = "user_id",property = "user",one = @One(select = "com.example.fresheveryday.mapper.UserMapper.selectById")),
            @Result(column = "product_id",property = "product",one = @One(select = "com.example.fresheveryday.mapper.ProductMapper.selectById"))
    })
    IPage<Comment> getAllComment(IPage<Comment> page);
}
